import cn.hutool.core.lang.Assert;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import de.siegmar.fastcsv.reader.CsvContainer;
import de.siegmar.fastcsv.reader.CsvReader;
import org.apache.commons.lang3.StringUtils;
import org.geotools.data.FeatureWriter;
import org.geotools.data.Transaction;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
import utilityTools.CustomizeType;
import utilityTools.ShpReaderUtil;

import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class OtherTests {

    private static String[] dizhi;
    private static String[] shichen;
    private static String[] shike;
    static {
        dizhi=new String[]{"子","丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
        shichen=new String[]{"夜半", "鸡鸣", "平旦", "日出", "食时", "隅中", "日平", "日昳", "晡时", "日入", "黄昏", "人定"};
        shike=new String[]{"一", "二", "三", "四", "五", "六", "七", "八"};
    }
    
    public void timeConvert(Date inputDate){
        if (inputDate == null) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 
//            inputDate=df.format(new Date());
            inputDate=new Date();
        }
    }

    public void timeConvert(Integer hour,Integer minute){
        //转换为‘几时几刻’
        String time_shichen=dizhi[hour/2]+"时("+shichen[hour/2]+")";
        if (hour%2==0) {
            time_shichen+=shike[minute/15+4];
        }else if (hour%2==1){
            time_shichen+=shike[minute/15];
        }
        time_shichen+="刻";
        System.out.println(time_shichen);
        System.out.println(46 / 15);//结果是3
    }

    public void get方位角(){
        String origin="108.78081,34.16115";
        String[] coordOrigin = origin.split(",");
        String destination="108.84284,34.12352";
        String[] coordDestination = destination.split(",");
        double angle2v1=this.getAngle(Double.parseDouble(coordOrigin[0]),Double.parseDouble(coordOrigin[1]),
                Double.parseDouble(coordDestination[0]),Double.parseDouble(coordDestination[1]));
        System.out.println("计算的角度是："+angle2v1);
        System.out.println("变更后的值："+angle2v1 + 180);
        angle2v1=angle2v1+180;
        if (angle2v1<90){
            System.out.println("东北");
        }else if (angle2v1<180){
            System.out.println("西北");
        }else if (angle2v1<270){
            System.out.println("西南");
        }else {
            System.out.println("东南");
        }
    }

    private double getAngle(double lng1,double lat1, double lng2,double lat2) {
        double dRotateAngle = Math.atan2(Math.abs(lng1 - lng2), Math.abs(lat1 - lat2));
        if (lng2 >= lng1) {
            if (lat2 >= lat1) {
            } else {
                dRotateAngle = Math.PI - dRotateAngle;
            }
        } else {
            if (lat2 >= lat1) {
                dRotateAngle = 2 * Math.PI - dRotateAngle;
            } else {
                dRotateAngle = Math.PI + dRotateAngle;
            }
        }
        dRotateAngle = dRotateAngle * 180 / Math.PI;
        return dRotateAngle;
    }
}
